<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>日期差计算器</title>
    <script>
        function cdate() {
            var startDate = new Date(document.getElementById("startDate").value);
            var endDate = new Date(document.getElementById("endDate").value);
            var timeDifference = endDate - startDate;
            var daysDifference = Math.ceil(timeDifference / (1000 * 60 * 60 * 24));
            document.getElementById("result").innerHTML = "两个日期相差 " + daysDifference + " 天";
        }
    </script>
</head>
<body>
    <h1>日期差计算器</h1>
    <label for="startDate">开始日期：</label>
    <input type="date" id="startDate">
    <br>
    <label for="endDate">结束日期：</label>
    <input type="date" id="endDate">
    <br>
    <button onclick="cdate()">计算天数差</button>
    <p id="result"></p>
</body>
</html>
